home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
56118
/
56118.xpi
/
chrome
/
content
/
common
/
toolbar-button-init.js
< prev
Wrap
Text File
|
2010-02-03
|
2KB
|
83 lines
// FIXME:geech:2009-03-10 - this could use some comments
// init
//dump("Loading toolbar code...");
var bccevernote_preference3 = "bccevernote.webclipper3.1.button.initialized";
function bccevernote_initEnClipperButton3() {
var prefs = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefService);
var db = prefs.getBranch(null);
try {
if (db.getBoolPref(bccevernote_preference3)) return;
}
catch(e) {
}
var buttonId = "bccwebclipper3-button";
var afterId;
var toolbarId;
// check toolbar
toolbarId = "nav-bar";
var tb = document.getElementById(toolbarId);
if (tb) {
afterId = "home-button";
} else {
toolbarId = "mail-bar";
tb = document.getElementById(toolbarId);
if (tb) {
afterId = "button-stop";
} else {
toolbarId = "composeToolbar";
tb = document.getElementById(toolbarId);
if (tb) {
afterId = "button-save";
} else {
return;
}
}
}
// check button
var currentSet = tb.getAttribute(tb.hasAttribute("currentset") ? "currentset" : "defaultset");
if (!currentSet) return;
db.setBoolPref(bccevernote_preference3, true);
var ids = currentSet.split(",");
var len = ids.length;
var j = -1;
for (var i = 0; i < len; i++) {
if (ids[i] == buttonId) return;
if (ids[i] == afterId) j = i;
}
// not found - add
var newSet;
if (j == -1) {
newSet = currentSet + "," + buttonId;
} else {
var k = 0;
for (var n = 0; n <= j ; n++) {
k = currentSet.indexOf(",", k) + 1;
}
newSet = currentSet.slice(0, k) + buttonId + "," + currentSet.slice(k);
}
tb.setAttribute("currentset", newSet);
tb.currentSet = newSet;
document.persist(toolbarId, "currentset");
// see http://developer.mozilla.org/en/docs/Code_snippets:Toolbar
try {
BrowserToolboxCustomizeDone(true);
}
catch (e) { }
}
window.addEventListener("load", bccevernote_initEnClipperButton3, false);